Merge branch 'mtimes-in-the-past' of https://github.com/integer32llc/cargo into mtime...
authorAlex Crichton <alex@alexcrichton.com>
Wed, 2 Nov 2016 16:14:25 +0000 (09:14 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 2 Nov 2016 16:14:25 +0000 (09:14 -0700)
1  2 
src/cargo/ops/cargo_rustc/fingerprint.rs
tests/freshness.rs

index 35074eefaf3f27bd9ef317d8212e93a1eb87ee3c,ae6275486795ddefaa6743db5fbe8fe1c20ced05..63a488cd3b9ff2c1ca181e0e9d0344c08f03ea47
@@@ -367,6 -358,70 +367,71 @@@ fn same_build_dir_cached_packages() 
      assert_that(p.cargo("build").cwd(p.root().join("a2")),
                  execs().with_status(0).with_stderr(&format!("\
  [COMPILING] a2 v0.0.1 ({dir}/a2)
 +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
  ", dir = p.url())));
  }
+ #[test]
+ fn no_rebuild_if_build_artifacts_move_backwards_in_time() {
+     let p = project("backwards_in_time")
+         .file("Cargo.toml", r#"
+             [package]
+             name = "backwards_in_time"
+             version = "0.0.1"
+             authors = []
+             [dependencies]
+             a = { path = "a" }
+         "#)
+         .file("src/lib.rs", "")
+         .file("a/Cargo.toml", r#"
+             [package]
+             name = "a"
+             version = "0.0.1"
+             authors = []
+         "#)
+         .file("a/src/lib.rs", "");
+     assert_that(p.cargo_process("build"),
+                 execs().with_status(0));
+     p.root().move_into_the_past();
+     p.root().join("target").move_into_the_past();
+     assert_that(p.cargo("build").env("RUST_LOG", ""),
+                 execs().with_status(0).with_stdout("").with_stderr(""));
+ }
+ #[test]
+ fn rebuild_if_build_artifacts_move_forward_in_time() {
+     let p = project("forwards_in_time")
+         .file("Cargo.toml", r#"
+             [package]
+             name = "forwards_in_time"
+             version = "0.0.1"
+             authors = []
+             [dependencies]
+             a = { path = "a" }
+         "#)
+         .file("src/lib.rs", "")
+         .file("a/Cargo.toml", r#"
+             [package]
+             name = "a"
+             version = "0.0.1"
+             authors = []
+         "#)
+         .file("a/src/lib.rs", "");
+     assert_that(p.cargo_process("build"),
+                 execs().with_status(0));
+     p.root().move_into_the_future();
+     p.root().join("target").move_into_the_future();
+     assert_that(p.cargo("build").env("RUST_LOG", ""),
+                 execs().with_status(0).with_stdout("").with_stderr("\
+ [COMPILING] a v0.0.1 ([..])
+ [COMPILING] forwards_in_time v0.0.1 ([..])
+ "));
+ }